<template>
    <div class="father">
      <h1>provide-inject Father组件</h1>
      <h1>Father有:{{ money }}万</h1>
      <h1>Father的车品牌:{{ car.brand }},价格:{{ car.price }}</h1>
      <Child/>
    </div>
  </template>
  
  <script lang="ts" setup>
    import { provide,ref,reactive } from "vue";
    import Child from './Child.vue'

    // 数据
    const money = ref(100)
    const car = reactive({
      brand: 'BMW',
      price: 500000
    })

    //方法
    function updateMoney(value:number){
      money.value -= value
    }

    // 向后代提供数据
    // provide('car',car)
    // provide('money',money)
    // provide('updateMoney',updateMoney)

    //一次性提供
    provide("fatherData",{car,money,updateMoney})
  </script>
  
  <style scoped>
  </style>